﻿Public Class TYPEDX
    Dim connect As CONDB = CONDB.NewConnection()
    'Dim connectlocal As conlocal = conlocal.NewConnection
    Dim PROVIDER_Check As New PROVIDERSCLASS

    Private Sub TYPEDX_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        SelectDatagridMASTYPEDX()

        DesignForm(Me)
        DesignGrid(mastypedxGrid)

        PROVIDER_Check.GETHOSEM(CInt(main.txtUserRequest.Text.Trim), Convert.ToString(Me.Tag))
    End Sub

    Private Sub SelectDatagridMASTYPEDX()
        Dim objSelectDataMASTYPEDX As New mastypedx
        Dim MASTYPEDX As DataTable
        MASTYPEDX = connect.GetTable(objSelectDataMASTYPEDX.selectMastypedx_)
        mastypedxGrid.PrimaryGrid.DataSource = MASTYPEDX
    End Sub

    Private Sub mastypedxGrid_CellClick(sender As Object, e As DevComponents.DotNetBar.SuperGrid.GridCellClickEventArgs) Handles mastypedxGrid.CellClick
        Dim grid As DevComponents.DotNetBar.SuperGrid.GridRow
        grid = e.GridPanel.ActiveRow
        'f.TXT_CID.Text = grid.Cells.Item(2).Value
        TYPEDXTxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("รหัสการวินิจฉัย").Value()
        TYPENAMETxt.Text = CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("การวินิจฉัย").Value()

        If CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value() = True Then
            mastypedxStatusChk.Checked = True
        Else
            mastypedxStatusChk.Checked = False
        End If

        Dim objChkboxUpdate As New CLICKGRIDCHECKBOX
        objChkboxUpdate.clickChkboxUpdate("mastypedx", CType(e.GridPanel.ActiveRow, DevComponents.DotNetBar.SuperGrid.GridRow).Cells("สถานะการเปิดใช้งาน").Value(), "STATUS", "TYPEDX", TYPEDXTxt.Text)
    End Sub

    Private Sub addMastypedx_Click(sender As Object, e As EventArgs) Handles addMastypedx.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PADD_ = True Then
                If TYPENAMETxt.Text.ToString.Length > 0 Then
                    Dim objInsertData As New mastypedx
                    objInsertData.TYPENAME_ = TYPENAMETxt.Text
                    objInsertData.STATUS_ = mastypedxStatusChk.Checked
                    objInsertData.insertMastypedxData()

                    SelectDatagridMASTYPEDX()

                    TYPEDXTxt.Text = ""
                    TYPENAMETxt.Text = ""
                    mastypedxStatusChk.Checked = False
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PADDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub editMastypedx_Click(sender As Object, e As EventArgs) Handles editMastypedx.Click
        If main.PROVIDERPOLICIES.checklogin_user_ = True Then
            If PROVIDER_Check.PUPD_ = True Then
                If TYPEDXTxt.Text.ToString.Length > 0 And TYPENAMETxt.Text.ToString.Length > 0 Then
                    Dim editStat As Integer
                    editStat = MsgBox("ท่านต้องการแก้ไขข้อมูลการวินิจฉัยดังกล่าวใช่หรือไม่", MsgBoxStyle.OkCancel)

                    If editStat = 1 Then
                        Dim objEditData As New mastypedx
                        objEditData.TYPEDX_ = TYPEDXTxt.Text
                        objEditData.TYPENAME_ = TYPENAMETxt.Text
                        objEditData.STATUS_ = mastypedxStatusChk.Checked
                        objEditData.editMastypedxData()

                        SelectDatagridMASTYPEDX()

                        TYPEDXTxt.Text = ""
                        TYPENAMETxt.Text = ""
                        mastypedxStatusChk.Checked = False
                    End If
                Else
                    MsgBox("โปรดระบุข้อมูลให้ครบถ้วน")
                End If
            Else
                MsgBox(PROVIDER_Check.PUPDMSG_)
            End If
        Else
            TOASTCLASS.gloadToastMSG(Me, main.PROVIDERPOLICIES.LOGINUSERMSG_)
            main.txtUserRequest.Focus()
        End If
    End Sub

    Private Sub importExel_Click(sender As Object, e As EventArgs) Handles importExel.Click
        Dim nextform As New IMPORTEXCEL("mastypedx")
        nextform.ShowDialog()
    End Sub

    Private Sub exportExcel_Click(sender As Object, e As EventArgs) Handles exportExcel.Click
        Dim nextform As New IMPORTEXCEL("mastypedx")
        nextform.ShowDialog()
    End Sub
End Class